package org.jeecg.modules.erp.base.service.impl;


import org.jeecg.modules.erp.base.entity.ErpWarehouse;
import org.jeecg.modules.erp.base.mapper.ErpWarehouseMapper;
import org.jeecg.modules.erp.base.service.IErpWarehouseService;
import org.jeecg.modules.erp.base.mapper.ErpWarehouseMapper;
import org.jeecg.modules.erp.base.service.IErpWarehouseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: erp_warehouse
 * @Author: jeecg-boot
 * @Date:   2024-05-17
 * @Version: V1.0
 */
@Service
public class ErpWarehouseServiceImpl extends ServiceImpl<ErpWarehouseMapper, ErpWarehouse> implements IErpWarehouseService {

	@Autowired
	private ErpWarehouseMapper erpWarehouseMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void saveMain(ErpWarehouse erpWarehouse ) {
		erpWarehouseMapper.insert(erpWarehouse);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateMain(ErpWarehouse erpWarehouse) {
		erpWarehouseMapper.updateById(erpWarehouse);
		
		//1.先删除子表数据
		
		//2.子表数据重新插入
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		erpWarehouseMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			erpWarehouseMapper.deleteById(id);
		}
	}

	@Override
	public ErpWarehouse selectByLocation(String locationId) {
		return erpWarehouseMapper.selectByLocation(locationId);
	}

}
